{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<function list.sort(*, key=None, reverse=False)>"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "test = pd.read_csv(\"/home/sunshuo/qml/TradeMaster-1/data/data/dj30/train.csv\",index_col=0)\n",
    "test.index.unique().tolist().sort()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "import torch\n",
    "from torch import nn\n",
    "m = nn.Softmax(dim=1)\n",
    "input = torch.randn(2, 3)\n",
    "output = m(input)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "tensor([[0.1535, 0.6031, 0.2435],\n",
       "        [0.9029, 0.0605, 0.0365]])"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "output"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "tensor([ 0.7530,  0.1940, -0.0454,  0.6175,  0.6000])"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "torch.cat([torch.randn(1),torch.randn(1),torch.randn(1),torch.randn(1),torch.randn(1)])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "tensor([[0.0827, 0.1401, 0.2361, 0.0792, 0.4619]])"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "m(torch.cat([torch.randn(1),torch.randn(1),torch.randn(1),torch.randn(1),torch.randn(1)]).unsqueeze(0))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "6"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "[1,2,3,4,5,6,777,8].index(777)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/home/sunshuo/miniconda3/envs/TradeMaster/lib/python3.7/site-packages/tqdm/auto.py:22: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
      "  from .autonotebook import tqdm as notebook_tqdm\n"
     ]
    }
   ],
   "source": [
    "import torch \n",
    "from torch.distributions import Normal\n",
    "normal = Normal(0, 2)\n",
    "result = normal.sample()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "tensor(-1.1969)"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "result"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "tensor(True)"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "result<=0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/home/sunshuo/miniconda3/envs/TradeMaster/lib/python3.7/site-packages/tqdm/auto.py:22: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
      "  from .autonotebook import tqdm as notebook_tqdm\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "tensor([1])"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import torch\n",
    "torch.tensor([torch.tensor(1)])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "normal = Normal(1, 2)\n",
    "result = normal.sample()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "tensor(-2.2420)"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "normal.log_prob(result)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "tensor(2)"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import torch \n",
    "torch.tensor(1)*torch.tensor(2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/home/sunshuo/miniconda3/envs/TradeMaster/lib/python3.7/site-packages/tqdm/auto.py:22: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
      "  from .autonotebook import tqdm as notebook_tqdm\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "tensor([0.0345, 0.0345, 0.0345, 0.0345, 0.0345, 0.0345, 0.0345, 0.0345, 0.0345,\n",
       "        0.0345, 0.0345, 0.0345, 0.0345, 0.0345, 0.0345, 0.0345, 0.0345, 0.0345,\n",
       "        0.0345, 0.0345, 0.0345, 0.0345, 0.0345, 0.0345, 0.0345, 0.0345, 0.0345,\n",
       "        0.0345, 0.0345])"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import torch\n",
    "torch.ones(29)*1/29"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>zopen</th>\n",
       "      <th>zhigh</th>\n",
       "      <th>zlow</th>\n",
       "      <th>zadjcp</th>\n",
       "      <th>zclose</th>\n",
       "      <th>zd_5</th>\n",
       "      <th>zd_10</th>\n",
       "      <th>zd_15</th>\n",
       "      <th>zd_20</th>\n",
       "      <th>zd_25</th>\n",
       "      <th>zd_30</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>-0.005008</td>\n",
       "      <td>0.005420</td>\n",
       "      <td>-0.012521</td>\n",
       "      <td>-0.212322</td>\n",
       "      <td>0.001038</td>\n",
       "      <td>0.001224</td>\n",
       "      <td>-0.009870</td>\n",
       "      <td>-0.012237</td>\n",
       "      <td>-0.018594</td>\n",
       "      <td>-0.026002</td>\n",
       "      <td>-0.027599</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>-0.007300</td>\n",
       "      <td>0.005003</td>\n",
       "      <td>-0.015596</td>\n",
       "      <td>-0.212322</td>\n",
       "      <td>0.003440</td>\n",
       "      <td>0.001224</td>\n",
       "      <td>-0.009870</td>\n",
       "      <td>-0.012237</td>\n",
       "      <td>-0.018594</td>\n",
       "      <td>-0.026002</td>\n",
       "      <td>-0.027599</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0.001156</td>\n",
       "      <td>0.006943</td>\n",
       "      <td>-0.007975</td>\n",
       "      <td>-0.212043</td>\n",
       "      <td>-0.001199</td>\n",
       "      <td>0.001224</td>\n",
       "      <td>-0.009870</td>\n",
       "      <td>-0.012237</td>\n",
       "      <td>-0.018594</td>\n",
       "      <td>-0.026002</td>\n",
       "      <td>-0.027599</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>-0.000333</td>\n",
       "      <td>0.005820</td>\n",
       "      <td>-0.008263</td>\n",
       "      <td>-0.212043</td>\n",
       "      <td>0.001803</td>\n",
       "      <td>-0.002500</td>\n",
       "      <td>-0.009870</td>\n",
       "      <td>-0.012237</td>\n",
       "      <td>-0.018594</td>\n",
       "      <td>-0.026002</td>\n",
       "      <td>-0.027599</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0.000571</td>\n",
       "      <td>0.007629</td>\n",
       "      <td>-0.007495</td>\n",
       "      <td>-0.212043</td>\n",
       "      <td>0.008054</td>\n",
       "      <td>-0.007629</td>\n",
       "      <td>-0.009870</td>\n",
       "      <td>-0.012237</td>\n",
       "      <td>-0.018594</td>\n",
       "      <td>-0.026002</td>\n",
       "      <td>-0.027599</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2006</th>\n",
       "      <td>0.001589</td>\n",
       "      <td>0.004278</td>\n",
       "      <td>-0.003463</td>\n",
       "      <td>-0.051178</td>\n",
       "      <td>-0.001137</td>\n",
       "      <td>-0.002803</td>\n",
       "      <td>-0.008433</td>\n",
       "      <td>-0.014390</td>\n",
       "      <td>-0.016835</td>\n",
       "      <td>-0.018877</td>\n",
       "      <td>-0.020440</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2007</th>\n",
       "      <td>-0.002547</td>\n",
       "      <td>0.002069</td>\n",
       "      <td>-0.005636</td>\n",
       "      <td>-0.051178</td>\n",
       "      <td>0.003603</td>\n",
       "      <td>-0.003561</td>\n",
       "      <td>-0.009250</td>\n",
       "      <td>-0.015527</td>\n",
       "      <td>-0.019168</td>\n",
       "      <td>-0.021174</td>\n",
       "      <td>-0.022697</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2008</th>\n",
       "      <td>0.000674</td>\n",
       "      <td>0.004389</td>\n",
       "      <td>-0.003894</td>\n",
       "      <td>-0.051178</td>\n",
       "      <td>0.001456</td>\n",
       "      <td>-0.003050</td>\n",
       "      <td>-0.008690</td>\n",
       "      <td>-0.014607</td>\n",
       "      <td>-0.019463</td>\n",
       "      <td>-0.021241</td>\n",
       "      <td>-0.023004</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2009</th>\n",
       "      <td>0.006716</td>\n",
       "      <td>0.009199</td>\n",
       "      <td>-0.003745</td>\n",
       "      <td>-0.051178</td>\n",
       "      <td>-0.006361</td>\n",
       "      <td>0.003072</td>\n",
       "      <td>-0.001060</td>\n",
       "      <td>-0.006952</td>\n",
       "      <td>-0.012213</td>\n",
       "      <td>-0.013740</td>\n",
       "      <td>-0.015699</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2010</th>\n",
       "      <td>-0.004321</td>\n",
       "      <td>0.001483</td>\n",
       "      <td>-0.007809</td>\n",
       "      <td>-0.051178</td>\n",
       "      <td>0.002872</td>\n",
       "      <td>0.000267</td>\n",
       "      <td>-0.002821</td>\n",
       "      <td>-0.008101</td>\n",
       "      <td>-0.013557</td>\n",
       "      <td>-0.015376</td>\n",
       "      <td>-0.017610</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>2011 rows × 11 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "         zopen     zhigh      zlow    zadjcp    zclose      zd_5     zd_10  \\\n",
       "0    -0.005008  0.005420 -0.012521 -0.212322  0.001038  0.001224 -0.009870   \n",
       "1    -0.007300  0.005003 -0.015596 -0.212322  0.003440  0.001224 -0.009870   \n",
       "2     0.001156  0.006943 -0.007975 -0.212043 -0.001199  0.001224 -0.009870   \n",
       "3    -0.000333  0.005820 -0.008263 -0.212043  0.001803 -0.002500 -0.009870   \n",
       "4     0.000571  0.007629 -0.007495 -0.212043  0.008054 -0.007629 -0.009870   \n",
       "...        ...       ...       ...       ...       ...       ...       ...   \n",
       "2006  0.001589  0.004278 -0.003463 -0.051178 -0.001137 -0.002803 -0.008433   \n",
       "2007 -0.002547  0.002069 -0.005636 -0.051178  0.003603 -0.003561 -0.009250   \n",
       "2008  0.000674  0.004389 -0.003894 -0.051178  0.001456 -0.003050 -0.008690   \n",
       "2009  0.006716  0.009199 -0.003745 -0.051178 -0.006361  0.003072 -0.001060   \n",
       "2010 -0.004321  0.001483 -0.007809 -0.051178  0.002872  0.000267 -0.002821   \n",
       "\n",
       "         zd_15     zd_20     zd_25     zd_30  \n",
       "0    -0.012237 -0.018594 -0.026002 -0.027599  \n",
       "1    -0.012237 -0.018594 -0.026002 -0.027599  \n",
       "2    -0.012237 -0.018594 -0.026002 -0.027599  \n",
       "3    -0.012237 -0.018594 -0.026002 -0.027599  \n",
       "4    -0.012237 -0.018594 -0.026002 -0.027599  \n",
       "...        ...       ...       ...       ...  \n",
       "2006 -0.014390 -0.016835 -0.018877 -0.020440  \n",
       "2007 -0.015527 -0.019168 -0.021174 -0.022697  \n",
       "2008 -0.014607 -0.019463 -0.021241 -0.023004  \n",
       "2009 -0.006952 -0.012213 -0.013740 -0.015699  \n",
       "2010 -0.008101 -0.013557 -0.015376 -0.017610  \n",
       "\n",
       "[2011 rows x 11 columns]"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "def make_market_information(df, technical_indicator):\n",
    "    #based on the information, calculate the average for technical_indicator to present the market average\n",
    "    all_dataframe_list = []\n",
    "    for i in range(df.index.unique()[-1] + 1):\n",
    "        information = df[df.index == i]\n",
    "        new_dataframe = []\n",
    "        for tech in technical_indicator:\n",
    "            tech_value = np.mean(information[tech])\n",
    "            new_dataframe.append(tech_value)\n",
    "        all_dataframe_list.append(new_dataframe)\n",
    "    new_df = pd.DataFrame(all_dataframe_list, columns=technical_indicator)\n",
    "    return new_df\n",
    "make_market_information(test, [\"zopen\",\"zhigh\", \"zlow\", \"zadjcp\", \"zclose\", \"zd_5\", \"zd_10\",\"zd_15\", \"zd_20\", \"zd_25\", \"zd_30\"])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "tensor([[ 0.3454,  2.8466],\n",
       "        [-1.5950, -0.2258]])"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import torch\n",
    "a=torch.randn(2,2)\n",
    "a"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "tensor(2.8466)"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a[0,-1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "tensor([True, True, True, True, True, True, True, True, True, True, True, True,\n",
       "        True, True, True, True, True, True, True, True])"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "torch.ones(20)==torch.ones(20)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "torch.ones(20).equal(torch.ones(20))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "technical_indicator=[\"zopen\",\"zhigh\", \"zlow\", \"zadjcp\", \"zclose\", \"zd_5\", \"zd_10\",\"zd_15\", \"zd_20\", \"zd_25\", \"zd_30\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>zopen</th>\n",
       "      <th>zhigh</th>\n",
       "      <th>zlow</th>\n",
       "      <th>zadjcp</th>\n",
       "      <th>zclose</th>\n",
       "      <th>zd_5</th>\n",
       "      <th>zd_10</th>\n",
       "      <th>zd_15</th>\n",
       "      <th>zd_20</th>\n",
       "      <th>zd_25</th>\n",
       "      <th>zd_30</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>-0.005008</td>\n",
       "      <td>0.005420</td>\n",
       "      <td>-0.012521</td>\n",
       "      <td>-0.212322</td>\n",
       "      <td>0.001038</td>\n",
       "      <td>0.001224</td>\n",
       "      <td>-0.009870</td>\n",
       "      <td>-0.012237</td>\n",
       "      <td>-0.018594</td>\n",
       "      <td>-0.026002</td>\n",
       "      <td>-0.027599</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>-0.007300</td>\n",
       "      <td>0.005003</td>\n",
       "      <td>-0.015596</td>\n",
       "      <td>-0.212322</td>\n",
       "      <td>0.003440</td>\n",
       "      <td>0.001224</td>\n",
       "      <td>-0.009870</td>\n",
       "      <td>-0.012237</td>\n",
       "      <td>-0.018594</td>\n",
       "      <td>-0.026002</td>\n",
       "      <td>-0.027599</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0.001156</td>\n",
       "      <td>0.006943</td>\n",
       "      <td>-0.007975</td>\n",
       "      <td>-0.212043</td>\n",
       "      <td>-0.001199</td>\n",
       "      <td>0.001224</td>\n",
       "      <td>-0.009870</td>\n",
       "      <td>-0.012237</td>\n",
       "      <td>-0.018594</td>\n",
       "      <td>-0.026002</td>\n",
       "      <td>-0.027599</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>-0.000333</td>\n",
       "      <td>0.005820</td>\n",
       "      <td>-0.008263</td>\n",
       "      <td>-0.212043</td>\n",
       "      <td>0.001803</td>\n",
       "      <td>-0.002500</td>\n",
       "      <td>-0.009870</td>\n",
       "      <td>-0.012237</td>\n",
       "      <td>-0.018594</td>\n",
       "      <td>-0.026002</td>\n",
       "      <td>-0.027599</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0.000571</td>\n",
       "      <td>0.007629</td>\n",
       "      <td>-0.007495</td>\n",
       "      <td>-0.212043</td>\n",
       "      <td>0.008054</td>\n",
       "      <td>-0.007629</td>\n",
       "      <td>-0.009870</td>\n",
       "      <td>-0.012237</td>\n",
       "      <td>-0.018594</td>\n",
       "      <td>-0.026002</td>\n",
       "      <td>-0.027599</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2006</th>\n",
       "      <td>0.001589</td>\n",
       "      <td>0.004278</td>\n",
       "      <td>-0.003463</td>\n",
       "      <td>-0.051178</td>\n",
       "      <td>-0.001137</td>\n",
       "      <td>-0.002803</td>\n",
       "      <td>-0.008433</td>\n",
       "      <td>-0.014390</td>\n",
       "      <td>-0.016835</td>\n",
       "      <td>-0.018877</td>\n",
       "      <td>-0.020440</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2007</th>\n",
       "      <td>-0.002547</td>\n",
       "      <td>0.002069</td>\n",
       "      <td>-0.005636</td>\n",
       "      <td>-0.051178</td>\n",
       "      <td>0.003603</td>\n",
       "      <td>-0.003561</td>\n",
       "      <td>-0.009250</td>\n",
       "      <td>-0.015527</td>\n",
       "      <td>-0.019168</td>\n",
       "      <td>-0.021174</td>\n",
       "      <td>-0.022697</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2008</th>\n",
       "      <td>0.000674</td>\n",
       "      <td>0.004389</td>\n",
       "      <td>-0.003894</td>\n",
       "      <td>-0.051178</td>\n",
       "      <td>0.001456</td>\n",
       "      <td>-0.003050</td>\n",
       "      <td>-0.008690</td>\n",
       "      <td>-0.014607</td>\n",
       "      <td>-0.019463</td>\n",
       "      <td>-0.021241</td>\n",
       "      <td>-0.023004</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2009</th>\n",
       "      <td>0.006716</td>\n",
       "      <td>0.009199</td>\n",
       "      <td>-0.003745</td>\n",
       "      <td>-0.051178</td>\n",
       "      <td>-0.006361</td>\n",
       "      <td>0.003072</td>\n",
       "      <td>-0.001060</td>\n",
       "      <td>-0.006952</td>\n",
       "      <td>-0.012213</td>\n",
       "      <td>-0.013740</td>\n",
       "      <td>-0.015699</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2010</th>\n",
       "      <td>-0.004321</td>\n",
       "      <td>0.001483</td>\n",
       "      <td>-0.007809</td>\n",
       "      <td>-0.051178</td>\n",
       "      <td>0.002872</td>\n",
       "      <td>0.000267</td>\n",
       "      <td>-0.002821</td>\n",
       "      <td>-0.008101</td>\n",
       "      <td>-0.013557</td>\n",
       "      <td>-0.015376</td>\n",
       "      <td>-0.017610</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>2011 rows × 11 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "         zopen     zhigh      zlow    zadjcp    zclose      zd_5     zd_10  \\\n",
       "0    -0.005008  0.005420 -0.012521 -0.212322  0.001038  0.001224 -0.009870   \n",
       "1    -0.007300  0.005003 -0.015596 -0.212322  0.003440  0.001224 -0.009870   \n",
       "2     0.001156  0.006943 -0.007975 -0.212043 -0.001199  0.001224 -0.009870   \n",
       "3    -0.000333  0.005820 -0.008263 -0.212043  0.001803 -0.002500 -0.009870   \n",
       "4     0.000571  0.007629 -0.007495 -0.212043  0.008054 -0.007629 -0.009870   \n",
       "...        ...       ...       ...       ...       ...       ...       ...   \n",
       "2006  0.001589  0.004278 -0.003463 -0.051178 -0.001137 -0.002803 -0.008433   \n",
       "2007 -0.002547  0.002069 -0.005636 -0.051178  0.003603 -0.003561 -0.009250   \n",
       "2008  0.000674  0.004389 -0.003894 -0.051178  0.001456 -0.003050 -0.008690   \n",
       "2009  0.006716  0.009199 -0.003745 -0.051178 -0.006361  0.003072 -0.001060   \n",
       "2010 -0.004321  0.001483 -0.007809 -0.051178  0.002872  0.000267 -0.002821   \n",
       "\n",
       "         zd_15     zd_20     zd_25     zd_30  \n",
       "0    -0.012237 -0.018594 -0.026002 -0.027599  \n",
       "1    -0.012237 -0.018594 -0.026002 -0.027599  \n",
       "2    -0.012237 -0.018594 -0.026002 -0.027599  \n",
       "3    -0.012237 -0.018594 -0.026002 -0.027599  \n",
       "4    -0.012237 -0.018594 -0.026002 -0.027599  \n",
       "...        ...       ...       ...       ...  \n",
       "2006 -0.014390 -0.016835 -0.018877 -0.020440  \n",
       "2007 -0.015527 -0.019168 -0.021174 -0.022697  \n",
       "2008 -0.014607 -0.019463 -0.021241 -0.023004  \n",
       "2009 -0.006952 -0.012213 -0.013740 -0.015699  \n",
       "2010 -0.008101 -0.013557 -0.015376 -0.017610  \n",
       "\n",
       "[2011 rows x 11 columns]"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "all_dataframe_list=[]\n",
    "for i in range(test.index.unique()[-1]+1):\n",
    "    information=test[test.index==i]\n",
    "    new_dataframe=[]\n",
    "    for tech in technical_indicator:\n",
    "        tech_value=np.mean(information[tech])\n",
    "        new_dataframe.append(tech_value)\n",
    "    all_dataframe_list.append(new_dataframe)\n",
    "new_df = pd.DataFrame(all_dataframe_list,columns=technical_indicator)    \n",
    "        \n",
    "new_df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "information=test[test.index==0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "55.76500340165763"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.mean(information[\"open\"])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(29, 29)"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "def correlation_coefficient_matrix():   \n",
    "    # get symbols\n",
    "    df = pd.read_csv(\"/home/sunshuo/qml/TradeMaster-1/data/data/dj30/train.csv\",index_col=0)\n",
    " \n",
    "    # sort symbols alphabetically\n",
    "    df.sort_values(by='tic', ascending=True, inplace=True)\n",
    "    array_symbols = df['tic'].values\n",
    "     \n",
    "    # get data, put into dictionary then dataframe\n",
    "    dict_sym_ac = {}  # key=symbol, value=array of adj close\n",
    "    for sym in array_symbols:\n",
    "        dftemp = df[df['tic']==sym]\n",
    "        dict_sym_ac[sym] = dftemp['adjcp'].values\n",
    "     \n",
    "    # create correlation coeff df\n",
    "    dfdata = pd.DataFrame.from_dict(dict_sym_ac)\n",
    "    dfcc = dfdata.corr().round(3)     \n",
    "    return dfcc\n",
    "df_corr=correlation_coefficient_matrix()\n",
    "df_corr.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "A=df_corr.values\n",
    "sum=np.sum(A,axis=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 1.08695652e+00, -3.36956522e-02,  9.78260870e-03,\n",
       "        -1.08695652e-02,  2.17391304e-03,  3.26086957e-03,\n",
       "         3.04347826e-02, -7.60869565e-03,  2.82608696e-02,\n",
       "         1.41304348e-02, -5.43478261e-03,  1.52173913e-02,\n",
       "         5.10869565e-02,  3.26086957e-02,  2.06521739e-02,\n",
       "         9.78260870e-03,  4.34782609e-03,  2.39130435e-02,\n",
       "         2.06521739e-02,  1.41304348e-02, -1.63043478e-02,\n",
       "        -1.30434783e-02, -8.69565217e-03, -3.69565217e-02,\n",
       "         2.82608696e-02, -2.60869565e-02,  2.39130435e-02,\n",
       "        -1.30434783e-02, -1.19565217e-02],\n",
       "       [-3.36956522e-02,  1.08695652e+00,  1.08695652e-03,\n",
       "        -6.52173913e-03,  1.30434783e-02,  1.08695652e-02,\n",
       "         2.60869565e-02,  5.54347826e-02, -1.08695652e-02,\n",
       "         6.52173913e-03, -2.71739130e-02, -1.19565217e-02,\n",
       "        -2.50000000e-02, -3.26086957e-03,  1.41304348e-02,\n",
       "        -2.17391304e-02, -3.26086957e-03, -1.08695652e-02,\n",
       "        -2.28260870e-02, -2.93478261e-02, -2.06521739e-02,\n",
       "        -4.13043478e-02, -3.26086957e-03,  4.89130435e-02,\n",
       "        -1.19565217e-02,  3.15217391e-02, -2.93478261e-02,\n",
       "         5.10869565e-02, -3.26086957e-02],\n",
       "       [ 9.78260870e-03,  1.08695652e-03,  1.08695652e+00,\n",
       "         1.95652174e-02,  7.60869565e-03, -1.73913043e-02,\n",
       "         2.60869565e-02,  2.39130435e-02,  4.13043478e-02,\n",
       "        -2.60869565e-02,  1.19565217e-02,  2.60869565e-02,\n",
       "         3.26086957e-03, -4.45652174e-02, -4.23913043e-02,\n",
       "         1.95652174e-02,  2.93478261e-02, -8.69565217e-03,\n",
       "        -1.52173913e-02, -1.95652174e-02, -2.50000000e-02,\n",
       "         1.41304348e-02, -4.02173913e-02, -9.78260870e-03,\n",
       "        -9.78260870e-03, -4.23913043e-02, -1.73913043e-02,\n",
       "        -3.26086957e-03,  6.52173913e-03],\n",
       "       [-1.08695652e-02, -6.52173913e-03,  1.95652174e-02,\n",
       "         1.08695652e+00,  3.36956522e-02, -1.19565217e-02,\n",
       "        -4.56521739e-02,  2.39130435e-02, -1.95652174e-02,\n",
       "        -1.52173913e-02, -2.17391304e-03,  2.39130435e-02,\n",
       "        -1.73913043e-02, -2.39130435e-02, -5.21739130e-02,\n",
       "         7.60869565e-03,  1.30434783e-02,  8.69565217e-03,\n",
       "        -1.30434783e-02, -4.67391304e-02,  2.28260870e-02,\n",
       "         3.91304348e-02, -5.65217391e-02, -3.47826087e-02,\n",
       "         2.39130435e-02,  1.08695652e-02, -2.28260870e-02,\n",
       "        -3.36956522e-02, -9.78260870e-03],\n",
       "       [ 2.17391304e-03,  1.30434783e-02,  7.60869565e-03,\n",
       "         3.36956522e-02,  1.08695652e+00,  0.00000000e+00,\n",
       "        -1.84782609e-02, -9.23913043e-02, -2.93478261e-02,\n",
       "         1.08695652e-03,  1.08695652e-02, -2.39130435e-02,\n",
       "        -1.41304348e-02,  3.26086957e-03,  1.71739130e-01,\n",
       "        -9.78260870e-03, -1.30434783e-02, -6.30434783e-02,\n",
       "         3.69565217e-02, -1.63043478e-02, -9.78260870e-03,\n",
       "         7.60869565e-03, -1.41304348e-02, -0.00000000e+00,\n",
       "        -1.84782609e-02,  0.00000000e+00,  4.34782609e-03,\n",
       "         1.30434783e-02, -3.26086957e-03],\n",
       "       [ 3.26086957e-03,  1.08695652e-02, -1.73913043e-02,\n",
       "        -1.19565217e-02,  0.00000000e+00,  1.08695652e+00,\n",
       "        -1.73913043e-02,  8.69565217e-03, -5.43478261e-02,\n",
       "        -3.58695652e-02, -5.43478261e-02, -5.43478261e-03,\n",
       "         2.17391304e-02, -5.10869565e-02,  6.52173913e-03,\n",
       "        -3.15217391e-02,  2.06521739e-02,  2.60869565e-02,\n",
       "         5.43478261e-03, -2.50000000e-02, -2.17391304e-03,\n",
       "        -1.84782609e-02,  2.82608696e-02,  3.26086957e-03,\n",
       "         4.34782609e-03, -1.63043478e-02,  1.52173913e-02,\n",
       "        -1.41304348e-02,  1.73913043e-02],\n",
       "       [ 3.04347826e-02,  2.60869565e-02,  2.60869565e-02,\n",
       "        -4.56521739e-02, -1.84782609e-02, -1.73913043e-02,\n",
       "         1.08695652e+00, -4.02173913e-02, -2.17391304e-03,\n",
       "         1.63043478e-02, -3.80434783e-02, -1.63043478e-02,\n",
       "         3.47826087e-02, -3.69565217e-02, -1.08695652e-03,\n",
       "        -3.47826087e-02, -3.47826087e-02,  4.34782609e-03,\n",
       "         4.56521739e-02, -1.73913043e-02, -4.34782609e-03,\n",
       "         8.69565217e-03, -6.52173913e-03,  1.08695652e-03,\n",
       "        -5.32608696e-02, -5.43478261e-03,  3.80434783e-02,\n",
       "         3.26086957e-03, -0.00000000e+00],\n",
       "       [-7.60869565e-03,  5.54347826e-02,  2.39130435e-02,\n",
       "         2.39130435e-02, -9.23913043e-02,  8.69565217e-03,\n",
       "        -4.02173913e-02,  1.08695652e+00, -3.26086957e-03,\n",
       "        -2.17391304e-03,  5.00000000e-02,  7.60869565e-03,\n",
       "        -2.93478261e-02, -3.69565217e-02, -3.42391304e-01,\n",
       "         2.28260870e-02,  2.17391304e-02,  4.45652174e-02,\n",
       "        -8.58695652e-02,  2.39130435e-02, -2.28260870e-02,\n",
       "        -5.65217391e-02,  3.04347826e-02,  2.82608696e-02,\n",
       "        -1.63043478e-02, -5.43478261e-03, -4.34782609e-02,\n",
       "        -1.08695652e-02, -9.78260870e-03],\n",
       "       [ 2.82608696e-02, -1.08695652e-02,  4.13043478e-02,\n",
       "        -1.95652174e-02, -2.93478261e-02, -5.43478261e-02,\n",
       "        -2.17391304e-03, -3.26086957e-03,  1.08695652e+00,\n",
       "         4.56521739e-02,  1.08695652e-03, -5.43478261e-03,\n",
       "         3.15217391e-02,  1.73913043e-02,  3.04347826e-02,\n",
       "         2.06521739e-02, -2.17391304e-02,  2.06521739e-02,\n",
       "         4.13043478e-02, -1.84782609e-02, -3.80434783e-02,\n",
       "        -2.17391304e-03, -3.26086957e-03, -3.80434783e-02,\n",
       "         6.52173913e-03,  7.60869565e-03, -2.17391304e-02,\n",
       "         3.04347826e-02, -3.15217391e-02],\n",
       "       [ 1.41304348e-02,  6.52173913e-03, -2.60869565e-02,\n",
       "        -1.52173913e-02,  1.08695652e-03, -3.58695652e-02,\n",
       "         1.63043478e-02, -2.17391304e-03,  4.56521739e-02,\n",
       "         1.08695652e+00,  3.26086957e-03,  4.34782609e-03,\n",
       "         7.60869565e-03,  2.60869565e-02,  3.15217391e-02,\n",
       "        -5.43478261e-03,  3.04347826e-02, -1.41304348e-02,\n",
       "        -5.43478261e-03,  7.60869565e-03, -5.43478261e-03,\n",
       "        -5.43478261e-03, -3.58695652e-02, -2.17391304e-03,\n",
       "         3.91304348e-02, -2.93478261e-02, -5.43478261e-03,\n",
       "         8.69565217e-03,  3.26086957e-03],\n",
       "       [-5.43478261e-03, -2.71739130e-02,  1.19565217e-02,\n",
       "        -2.17391304e-03,  1.08695652e-02, -5.43478261e-02,\n",
       "        -3.80434783e-02,  5.00000000e-02,  1.08695652e-03,\n",
       "         3.26086957e-03,  1.08695652e+00, -6.52173913e-03,\n",
       "        -3.26086957e-03,  3.36956522e-02, -3.58695652e-02,\n",
       "        -2.82608696e-02,  1.30434783e-02,  5.43478261e-03,\n",
       "        -1.30434783e-02,  8.69565217e-03, -7.60869565e-03,\n",
       "         2.06521739e-02,  2.28260870e-02,  1.30434783e-02,\n",
       "         9.78260870e-03, -7.60869565e-03,  2.06521739e-02,\n",
       "        -4.34782609e-03,  1.41304348e-02],\n",
       "       [ 1.52173913e-02, -1.19565217e-02,  2.60869565e-02,\n",
       "         2.39130435e-02, -2.39130435e-02, -5.43478261e-03,\n",
       "        -1.63043478e-02,  7.60869565e-03, -5.43478261e-03,\n",
       "         4.34782609e-03, -6.52173913e-03,  1.08695652e+00,\n",
       "        -1.73913043e-02, -2.82608696e-02, -5.43478261e-03,\n",
       "         2.60869565e-02,  3.26086957e-02,  1.63043478e-02,\n",
       "        -2.28260870e-02,  1.08695652e-02, -9.78260870e-03,\n",
       "         9.78260870e-03,  4.34782609e-03,  4.34782609e-03,\n",
       "        -5.54347826e-02, -1.08695652e-02, -6.52173913e-03,\n",
       "        -2.28260870e-02, -2.93478261e-02],\n",
       "       [ 5.10869565e-02, -2.50000000e-02,  3.26086957e-03,\n",
       "        -1.73913043e-02, -1.41304348e-02,  2.17391304e-02,\n",
       "         3.47826087e-02, -2.93478261e-02,  3.15217391e-02,\n",
       "         7.60869565e-03, -3.26086957e-03, -1.73913043e-02,\n",
       "         1.08695652e+00,  1.08695652e-02,  8.36956522e-02,\n",
       "        -2.93478261e-02,  1.30434783e-02,  1.95652174e-02,\n",
       "        -2.50000000e-02,  2.82608696e-02, -4.56521739e-02,\n",
       "         5.43478261e-03,  4.23913043e-02, -1.08695652e-02,\n",
       "         4.67391304e-02,  2.82608696e-02, -3.58695652e-02,\n",
       "        -9.78260870e-03, -3.15217391e-02],\n",
       "       [ 3.26086957e-02, -3.26086957e-03, -4.45652174e-02,\n",
       "        -2.39130435e-02,  3.26086957e-03, -5.10869565e-02,\n",
       "        -3.69565217e-02, -3.69565217e-02,  1.73913043e-02,\n",
       "         2.60869565e-02,  3.36956522e-02, -2.82608696e-02,\n",
       "         1.08695652e-02,  1.08695652e+00, -8.69565217e-03,\n",
       "        -4.13043478e-02,  1.95652174e-02, -4.67391304e-02,\n",
       "         9.78260870e-03, -5.10869565e-02,  4.34782609e-03,\n",
       "         9.78260870e-03,  2.50000000e-02, -1.30434783e-02,\n",
       "         1.30434783e-02, -4.34782609e-03,  1.84782609e-02,\n",
       "        -3.26086957e-02,  6.08695652e-02],\n",
       "       [ 2.06521739e-02,  1.41304348e-02, -4.23913043e-02,\n",
       "        -5.21739130e-02,  1.71739130e-01,  6.52173913e-03,\n",
       "        -1.08695652e-03, -3.42391304e-01,  3.04347826e-02,\n",
       "         3.15217391e-02, -3.58695652e-02, -5.43478261e-03,\n",
       "         8.36956522e-02, -8.69565217e-03,  1.08695652e+00,\n",
       "        -3.58695652e-02, -4.45652174e-02, -2.82608696e-02,\n",
       "         1.46739130e-01, -3.36956522e-02,  8.69565217e-03,\n",
       "         8.69565217e-02, -1.41304348e-02,  3.26086957e-03,\n",
       "         1.08695652e-03, -2.17391304e-03, -2.28260870e-02,\n",
       "         4.34782609e-03, -1.41304348e-02],\n",
       "       [ 9.78260870e-03, -2.17391304e-02,  1.95652174e-02,\n",
       "         7.60869565e-03, -9.78260870e-03, -3.15217391e-02,\n",
       "        -3.47826087e-02,  2.28260870e-02,  2.06521739e-02,\n",
       "        -5.43478261e-03, -2.82608696e-02,  2.60869565e-02,\n",
       "        -2.93478261e-02, -4.13043478e-02, -3.58695652e-02,\n",
       "         1.08695652e+00, -5.43478261e-03, -1.19565217e-02,\n",
       "        -2.71739130e-02,  7.60869565e-03, -2.93478261e-02,\n",
       "        -1.30434783e-02, -9.78260870e-03,  2.17391304e-03,\n",
       "         3.58695652e-02, -8.69565217e-03,  2.93478261e-02,\n",
       "        -2.93478261e-02, -2.50000000e-02],\n",
       "       [ 4.34782609e-03, -3.26086957e-03,  2.93478261e-02,\n",
       "         1.30434783e-02, -1.30434783e-02,  2.06521739e-02,\n",
       "        -3.47826087e-02,  2.17391304e-02, -2.17391304e-02,\n",
       "         3.04347826e-02,  1.30434783e-02,  3.26086957e-02,\n",
       "         1.30434783e-02,  1.95652174e-02, -4.45652174e-02,\n",
       "        -5.43478261e-03,  1.08695652e+00, -4.34782609e-03,\n",
       "         4.56521739e-02, -1.73913043e-02,  4.56521739e-02,\n",
       "        -1.08695652e-03,  1.08695652e-03,  2.28260870e-02,\n",
       "         2.17391304e-02,  4.34782609e-03, -1.08695652e-03,\n",
       "        -3.26086957e-02,  1.08695652e-02],\n",
       "       [ 2.39130435e-02, -1.08695652e-02, -8.69565217e-03,\n",
       "         8.69565217e-03, -6.30434783e-02,  2.60869565e-02,\n",
       "         4.34782609e-03,  4.45652174e-02,  2.06521739e-02,\n",
       "        -1.41304348e-02,  5.43478261e-03,  1.63043478e-02,\n",
       "         1.95652174e-02, -4.67391304e-02, -2.82608696e-02,\n",
       "        -1.19565217e-02, -4.34782609e-03,  1.08695652e+00,\n",
       "         1.08695652e-03,  4.67391304e-02,  6.52173913e-03,\n",
       "         1.95652174e-02, -8.69565217e-03, -2.06521739e-02,\n",
       "        -3.26086957e-03,  2.17391304e-03,  1.19565217e-02,\n",
       "        -2.82608696e-02, -2.82608696e-02],\n",
       "       [ 2.06521739e-02, -2.28260870e-02, -1.52173913e-02,\n",
       "        -1.30434783e-02,  3.69565217e-02,  5.43478261e-03,\n",
       "         4.56521739e-02, -8.58695652e-02,  4.13043478e-02,\n",
       "        -5.43478261e-03, -1.30434783e-02, -2.28260870e-02,\n",
       "        -2.50000000e-02,  9.78260870e-03,  1.46739130e-01,\n",
       "        -2.71739130e-02,  4.56521739e-02,  1.08695652e-03,\n",
       "         1.08695652e+00, -2.50000000e-02,  2.06521739e-02,\n",
       "         1.73913043e-02,  2.71739130e-02,  5.10869565e-02,\n",
       "        -6.52173913e-03, -7.60869565e-03,  5.10869565e-02,\n",
       "        -2.82608696e-02, -1.73913043e-02],\n",
       "       [ 1.41304348e-02, -2.93478261e-02, -1.95652174e-02,\n",
       "        -4.67391304e-02, -1.63043478e-02, -2.50000000e-02,\n",
       "        -1.73913043e-02,  2.39130435e-02, -1.84782609e-02,\n",
       "         7.60869565e-03,  8.69565217e-03,  1.08695652e-02,\n",
       "         2.82608696e-02, -5.10869565e-02, -3.36956522e-02,\n",
       "         7.60869565e-03, -1.73913043e-02,  4.67391304e-02,\n",
       "        -2.50000000e-02,  1.08695652e+00, -2.93478261e-02,\n",
       "        -4.13043478e-02,  1.84782609e-02,  2.93478261e-02,\n",
       "         1.30434783e-02, -1.73913043e-02,  3.26086957e-02,\n",
       "        -9.78260870e-03,  1.73913043e-02],\n",
       "       [-1.63043478e-02, -2.06521739e-02, -2.50000000e-02,\n",
       "         2.28260870e-02, -9.78260870e-03, -2.17391304e-03,\n",
       "        -4.34782609e-03, -2.28260870e-02, -3.80434783e-02,\n",
       "        -5.43478261e-03, -7.60869565e-03, -9.78260870e-03,\n",
       "        -4.56521739e-02,  4.34782609e-03,  8.69565217e-03,\n",
       "        -2.93478261e-02,  4.56521739e-02,  6.52173913e-03,\n",
       "         2.06521739e-02, -2.93478261e-02,  1.08695652e+00,\n",
       "         1.19565217e-02, -2.06521739e-02, -3.26086957e-03,\n",
       "        -2.17391304e-03, -3.15217391e-02, -0.00000000e+00,\n",
       "         3.15217391e-02, -3.15217391e-02],\n",
       "       [-1.30434783e-02, -4.13043478e-02,  1.41304348e-02,\n",
       "         3.91304348e-02,  7.60869565e-03, -1.84782609e-02,\n",
       "         8.69565217e-03, -5.65217391e-02, -2.17391304e-03,\n",
       "        -5.43478261e-03,  2.06521739e-02,  9.78260870e-03,\n",
       "         5.43478261e-03,  9.78260870e-03,  8.69565217e-02,\n",
       "        -1.30434783e-02, -1.08695652e-03,  1.95652174e-02,\n",
       "         1.73913043e-02, -4.13043478e-02,  1.19565217e-02,\n",
       "         1.08695652e+00, -7.60869565e-03, -2.17391304e-03,\n",
       "        -2.60869565e-02, -3.04347826e-02,  1.08695652e-02,\n",
       "        -2.60869565e-02,  5.00000000e-02],\n",
       "       [-8.69565217e-03, -3.26086957e-03, -4.02173913e-02,\n",
       "        -5.65217391e-02, -1.41304348e-02,  2.82608696e-02,\n",
       "        -6.52173913e-03,  3.04347826e-02, -3.26086957e-03,\n",
       "        -3.58695652e-02,  2.28260870e-02,  4.34782609e-03,\n",
       "         4.23913043e-02,  2.50000000e-02, -1.41304348e-02,\n",
       "        -9.78260870e-03,  1.08695652e-03, -8.69565217e-03,\n",
       "         2.71739130e-02,  1.84782609e-02, -2.06521739e-02,\n",
       "        -7.60869565e-03,  1.08695652e+00,  3.58695652e-02,\n",
       "        -2.82608696e-02, -7.60869565e-03,  1.73913043e-02,\n",
       "        -2.60869565e-02, -3.15217391e-02],\n",
       "       [-3.69565217e-02,  4.89130435e-02, -9.78260870e-03,\n",
       "        -3.47826087e-02, -0.00000000e+00,  3.26086957e-03,\n",
       "         1.08695652e-03,  2.82608696e-02, -3.80434783e-02,\n",
       "        -2.17391304e-03,  1.30434783e-02,  4.34782609e-03,\n",
       "        -1.08695652e-02, -1.30434783e-02,  3.26086957e-03,\n",
       "         2.17391304e-03,  2.28260870e-02, -2.06521739e-02,\n",
       "         5.10869565e-02,  2.93478261e-02, -3.26086957e-03,\n",
       "        -2.17391304e-03,  3.58695652e-02,  1.08695652e+00,\n",
       "        -2.28260870e-02,  4.56521739e-02, -7.60869565e-03,\n",
       "        -1.19565217e-02, -2.71739130e-02],\n",
       "       [ 2.82608696e-02, -1.19565217e-02, -9.78260870e-03,\n",
       "         2.39130435e-02, -1.84782609e-02,  4.34782609e-03,\n",
       "        -5.32608696e-02, -1.63043478e-02,  6.52173913e-03,\n",
       "         3.91304348e-02,  9.78260870e-03, -5.54347826e-02,\n",
       "         4.67391304e-02,  1.30434783e-02,  1.08695652e-03,\n",
       "         3.58695652e-02,  2.17391304e-02, -3.26086957e-03,\n",
       "        -6.52173913e-03,  1.30434783e-02, -2.17391304e-03,\n",
       "        -2.60869565e-02, -2.82608696e-02, -2.28260870e-02,\n",
       "         1.08695652e+00,  2.17391304e-03, -1.30434783e-02,\n",
       "        -5.10869565e-02,  2.28260870e-02],\n",
       "       [-2.60869565e-02,  3.15217391e-02, -4.23913043e-02,\n",
       "         1.08695652e-02,  0.00000000e+00, -1.63043478e-02,\n",
       "        -5.43478261e-03, -5.43478261e-03,  7.60869565e-03,\n",
       "        -2.93478261e-02, -7.60869565e-03, -1.08695652e-02,\n",
       "         2.82608696e-02, -4.34782609e-03, -2.17391304e-03,\n",
       "        -8.69565217e-03,  4.34782609e-03,  2.17391304e-03,\n",
       "        -7.60869565e-03, -1.73913043e-02, -3.15217391e-02,\n",
       "        -3.04347826e-02, -7.60869565e-03,  4.56521739e-02,\n",
       "         2.17391304e-03,  1.08695652e+00,  1.08695652e-02,\n",
       "         3.26086957e-03, -2.71739130e-02],\n",
       "       [ 2.39130435e-02, -2.93478261e-02, -1.73913043e-02,\n",
       "        -2.28260870e-02,  4.34782609e-03,  1.52173913e-02,\n",
       "         3.80434783e-02, -4.34782609e-02, -2.17391304e-02,\n",
       "        -5.43478261e-03,  2.06521739e-02, -6.52173913e-03,\n",
       "        -3.58695652e-02,  1.84782609e-02, -2.28260870e-02,\n",
       "         2.93478261e-02, -1.08695652e-03,  1.19565217e-02,\n",
       "         5.10869565e-02,  3.26086957e-02, -0.00000000e+00,\n",
       "         1.08695652e-02,  1.73913043e-02, -7.60869565e-03,\n",
       "        -1.30434783e-02,  1.08695652e-02,  1.08695652e+00,\n",
       "         2.50000000e-02, -1.63043478e-02],\n",
       "       [-1.30434783e-02,  5.10869565e-02, -3.26086957e-03,\n",
       "        -3.36956522e-02,  1.30434783e-02, -1.41304348e-02,\n",
       "         3.26086957e-03, -1.08695652e-02,  3.04347826e-02,\n",
       "         8.69565217e-03, -4.34782609e-03, -2.28260870e-02,\n",
       "        -9.78260870e-03, -3.26086957e-02,  4.34782609e-03,\n",
       "        -2.93478261e-02, -3.26086957e-02, -2.82608696e-02,\n",
       "        -2.82608696e-02, -9.78260870e-03,  3.15217391e-02,\n",
       "        -2.60869565e-02, -2.60869565e-02, -1.19565217e-02,\n",
       "        -5.10869565e-02,  3.26086957e-03,  2.50000000e-02,\n",
       "         1.08695652e+00, -2.17391304e-02],\n",
       "       [-1.19565217e-02, -3.26086957e-02,  6.52173913e-03,\n",
       "        -9.78260870e-03, -3.26086957e-03,  1.73913043e-02,\n",
       "        -0.00000000e+00, -9.78260870e-03, -3.15217391e-02,\n",
       "         3.26086957e-03,  1.41304348e-02, -2.93478261e-02,\n",
       "        -3.15217391e-02,  6.08695652e-02, -1.41304348e-02,\n",
       "        -2.50000000e-02,  1.08695652e-02, -2.82608696e-02,\n",
       "        -1.73913043e-02,  1.73913043e-02, -3.15217391e-02,\n",
       "         5.00000000e-02, -3.15217391e-02, -2.71739130e-02,\n",
       "         2.28260870e-02, -2.71739130e-02, -1.63043478e-02,\n",
       "        -2.17391304e-02,  1.08695652e+00]])"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "A/sum[1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [],
   "source": [
    "a=np.array([[1,2],[2,3]])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [],
   "source": [
    "sum=np.sum(a,axis=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[0.33333333, 0.66666667],\n",
       "       [0.4       , 0.6       ]])"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "(a.T/sum).T"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([3, 5])"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sum"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [],
   "source": [
    "import torch\n",
    "from torch import nn\n",
    "corr_tensor=torch.from_numpy(df_corr.values/df_corr.values.sum(0)).to(torch.float)\n",
    "H_L=torch.randn(12,29,10)\n",
    "theta=torch.randn(10,10)\n",
    "Z_l=torch.matmul(torch.matmul(corr_tensor,H_L),theta)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "torch.Size([12, 29, 10])"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Z_l.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "torch.Size([12, 10, 29])"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "torch.matmul(torch.randn(29,29),Z_l).transpose(1,2).shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "torch.Size([12, 10, 29])"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "(torch.matmul(torch.randn(29,29),Z_l).transpose(1,2)+H_L.transpose(1,2)).shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "torch.Size([29, 120])"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "(torch.matmul(torch.randn(29,29),Z_l).transpose(1,2)+H_L.transpose(1,2)).transpose(0,2).reshape(29,-1).shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {},
   "outputs": [],
   "source": [
    "linear_layer=nn.Linear(120,1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "tensor([[-13.2055, -24.7030,  29.8546,  ...,  25.4757,  -1.3610,  19.2618],\n",
       "        [  0.8493, -16.8559,  16.3238,  ...,  -4.8107,  -3.2931, -12.7132],\n",
       "        [-40.8551,  17.8643,  -8.9494,  ...,  10.4244, -17.1789, -18.5953],\n",
       "        ...,\n",
       "        [ 25.7935,  54.3993,  -7.8799,  ...,   0.3189,  17.8442, -33.6028],\n",
       "        [  3.2274,   0.0853, -23.1604,  ..., -37.0744,  34.7043,  24.7538],\n",
       "        [ 27.0065,  22.3388,  -2.3154,  ...,  -8.6641,  13.4049,  -6.5285]])"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "(torch.matmul(torch.randn(29,29),Z_l).transpose(1,2)+H_L.transpose(1,2)).transpose(0,2).reshape(29,-1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "tensor([[1.0000e+00],\n",
       "        [3.2447e-01],\n",
       "        [9.9969e-01],\n",
       "        [1.4937e-04],\n",
       "        [4.0361e-02],\n",
       "        [7.7116e-06],\n",
       "        [9.9732e-01],\n",
       "        [1.0000e+00],\n",
       "        [7.3402e-03],\n",
       "        [2.7902e-03],\n",
       "        [2.0375e-01],\n",
       "        [1.5507e-07],\n",
       "        [1.0000e+00],\n",
       "        [1.0000e+00],\n",
       "        [8.5462e-01],\n",
       "        [3.1817e-03],\n",
       "        [1.0604e-01],\n",
       "        [1.0000e+00],\n",
       "        [9.9931e-01],\n",
       "        [1.3850e-02],\n",
       "        [9.9925e-01],\n",
       "        [1.0000e+00],\n",
       "        [1.0000e+00],\n",
       "        [1.3817e-12],\n",
       "        [2.0878e-02],\n",
       "        [1.0000e+00],\n",
       "        [9.9998e-01],\n",
       "        [2.6425e-04],\n",
       "        [5.5056e-06]], grad_fn=<SigmoidBackward0>)"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "v=torch.sigmoid(linear_layer((torch.matmul(torch.randn(29,29),Z_l).transpose(1,2)+H_L.transpose(1,2)).transpose(0,2).reshape(29,-1)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>date</th>\n",
       "      <th>open</th>\n",
       "      <th>high</th>\n",
       "      <th>low</th>\n",
       "      <th>close</th>\n",
       "      <th>adjcp</th>\n",
       "      <th>tic</th>\n",
       "      <th>zopen</th>\n",
       "      <th>zhigh</th>\n",
       "      <th>zlow</th>\n",
       "      <th>zadjcp</th>\n",
       "      <th>zclose</th>\n",
       "      <th>zd_5</th>\n",
       "      <th>zd_10</th>\n",
       "      <th>zd_15</th>\n",
       "      <th>zd_20</th>\n",
       "      <th>zd_25</th>\n",
       "      <th>zd_30</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2012-01-04</td>\n",
       "      <td>24.747499</td>\n",
       "      <td>24.875000</td>\n",
       "      <td>24.070000</td>\n",
       "      <td>24.370001</td>\n",
       "      <td>24.370001</td>\n",
       "      <td>CRM</td>\n",
       "      <td>0.015490</td>\n",
       "      <td>0.020722</td>\n",
       "      <td>-0.012310</td>\n",
       "      <td>0.0</td>\n",
       "      <td>-0.036759</td>\n",
       "      <td>-0.000532</td>\n",
       "      <td>-0.014879</td>\n",
       "      <td>-0.015927</td>\n",
       "      <td>-0.017220</td>\n",
       "      <td>-0.024889</td>\n",
       "      <td>-0.023492</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2012-01-05</td>\n",
       "      <td>24.235001</td>\n",
       "      <td>24.987499</td>\n",
       "      <td>23.790001</td>\n",
       "      <td>24.692499</td>\n",
       "      <td>24.692499</td>\n",
       "      <td>CRM</td>\n",
       "      <td>-0.018528</td>\n",
       "      <td>0.011947</td>\n",
       "      <td>-0.036549</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.013233</td>\n",
       "      <td>-0.000532</td>\n",
       "      <td>-0.014879</td>\n",
       "      <td>-0.015927</td>\n",
       "      <td>-0.017220</td>\n",
       "      <td>-0.024889</td>\n",
       "      <td>-0.023492</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2012-01-06</td>\n",
       "      <td>24.745001</td>\n",
       "      <td>25.312500</td>\n",
       "      <td>24.212500</td>\n",
       "      <td>25.264999</td>\n",
       "      <td>25.264999</td>\n",
       "      <td>CRM</td>\n",
       "      <td>-0.020582</td>\n",
       "      <td>0.001880</td>\n",
       "      <td>-0.041658</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.023185</td>\n",
       "      <td>-0.000532</td>\n",
       "      <td>-0.014879</td>\n",
       "      <td>-0.015927</td>\n",
       "      <td>-0.017220</td>\n",
       "      <td>-0.024889</td>\n",
       "      <td>-0.023492</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2012-01-09</td>\n",
       "      <td>25.205000</td>\n",
       "      <td>25.459999</td>\n",
       "      <td>24.882500</td>\n",
       "      <td>25.187500</td>\n",
       "      <td>25.187500</td>\n",
       "      <td>CRM</td>\n",
       "      <td>0.000695</td>\n",
       "      <td>0.010819</td>\n",
       "      <td>-0.012109</td>\n",
       "      <td>0.0</td>\n",
       "      <td>-0.003067</td>\n",
       "      <td>-0.008913</td>\n",
       "      <td>-0.014879</td>\n",
       "      <td>-0.015927</td>\n",
       "      <td>-0.017220</td>\n",
       "      <td>-0.024889</td>\n",
       "      <td>-0.023492</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2012-01-10</td>\n",
       "      <td>25.695000</td>\n",
       "      <td>26.202499</td>\n",
       "      <td>25.415001</td>\n",
       "      <td>26.197500</td>\n",
       "      <td>26.197500</td>\n",
       "      <td>CRM</td>\n",
       "      <td>-0.019181</td>\n",
       "      <td>0.000191</td>\n",
       "      <td>-0.029869</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.040099</td>\n",
       "      <td>-0.040271</td>\n",
       "      <td>-0.014879</td>\n",
       "      <td>-0.015927</td>\n",
       "      <td>-0.017220</td>\n",
       "      <td>-0.024889</td>\n",
       "      <td>-0.023492</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2006</th>\n",
       "      <td>2019-12-24</td>\n",
       "      <td>163.309998</td>\n",
       "      <td>163.839996</td>\n",
       "      <td>162.880005</td>\n",
       "      <td>163.250000</td>\n",
       "      <td>163.250000</td>\n",
       "      <td>CRM</td>\n",
       "      <td>0.000368</td>\n",
       "      <td>0.003614</td>\n",
       "      <td>-0.002266</td>\n",
       "      <td>0.0</td>\n",
       "      <td>-0.002993</td>\n",
       "      <td>0.000123</td>\n",
       "      <td>-0.010077</td>\n",
       "      <td>-0.018850</td>\n",
       "      <td>-0.016202</td>\n",
       "      <td>-0.013131</td>\n",
       "      <td>-0.011302</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2007</th>\n",
       "      <td>2019-12-26</td>\n",
       "      <td>163.399994</td>\n",
       "      <td>164.529999</td>\n",
       "      <td>163.270004</td>\n",
       "      <td>164.509995</td>\n",
       "      <td>164.509995</td>\n",
       "      <td>CRM</td>\n",
       "      <td>-0.006747</td>\n",
       "      <td>0.000122</td>\n",
       "      <td>-0.007537</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.007718</td>\n",
       "      <td>-0.003854</td>\n",
       "      <td>-0.012723</td>\n",
       "      <td>-0.023091</td>\n",
       "      <td>-0.023138</td>\n",
       "      <td>-0.020556</td>\n",
       "      <td>-0.018540</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2008</th>\n",
       "      <td>2019-12-27</td>\n",
       "      <td>164.860001</td>\n",
       "      <td>165.460007</td>\n",
       "      <td>163.899994</td>\n",
       "      <td>164.979996</td>\n",
       "      <td>164.979996</td>\n",
       "      <td>CRM</td>\n",
       "      <td>-0.000727</td>\n",
       "      <td>0.002910</td>\n",
       "      <td>-0.006546</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.002857</td>\n",
       "      <td>-0.004691</td>\n",
       "      <td>-0.011662</td>\n",
       "      <td>-0.023142</td>\n",
       "      <td>-0.024870</td>\n",
       "      <td>-0.023157</td>\n",
       "      <td>-0.020855</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2009</th>\n",
       "      <td>2019-12-30</td>\n",
       "      <td>164.860001</td>\n",
       "      <td>164.940002</td>\n",
       "      <td>161.199997</td>\n",
       "      <td>162.440002</td>\n",
       "      <td>162.440002</td>\n",
       "      <td>CRM</td>\n",
       "      <td>0.014898</td>\n",
       "      <td>0.015390</td>\n",
       "      <td>-0.007634</td>\n",
       "      <td>0.0</td>\n",
       "      <td>-0.015396</td>\n",
       "      <td>0.008274</td>\n",
       "      <td>0.004599</td>\n",
       "      <td>-0.006049</td>\n",
       "      <td>-0.009761</td>\n",
       "      <td>-0.007991</td>\n",
       "      <td>-0.005670</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2010</th>\n",
       "      <td>2019-12-31</td>\n",
       "      <td>162.039993</td>\n",
       "      <td>163.259995</td>\n",
       "      <td>161.800003</td>\n",
       "      <td>162.639999</td>\n",
       "      <td>162.639999</td>\n",
       "      <td>CRM</td>\n",
       "      <td>-0.003689</td>\n",
       "      <td>0.003812</td>\n",
       "      <td>-0.005165</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.001231</td>\n",
       "      <td>0.005681</td>\n",
       "      <td>0.003781</td>\n",
       "      <td>-0.005157</td>\n",
       "      <td>-0.010474</td>\n",
       "      <td>-0.009252</td>\n",
       "      <td>-0.007009</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>2011 rows × 18 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "            date        open        high         low       close       adjcp  \\\n",
       "0     2012-01-04   24.747499   24.875000   24.070000   24.370001   24.370001   \n",
       "1     2012-01-05   24.235001   24.987499   23.790001   24.692499   24.692499   \n",
       "2     2012-01-06   24.745001   25.312500   24.212500   25.264999   25.264999   \n",
       "3     2012-01-09   25.205000   25.459999   24.882500   25.187500   25.187500   \n",
       "4     2012-01-10   25.695000   26.202499   25.415001   26.197500   26.197500   \n",
       "...          ...         ...         ...         ...         ...         ...   \n",
       "2006  2019-12-24  163.309998  163.839996  162.880005  163.250000  163.250000   \n",
       "2007  2019-12-26  163.399994  164.529999  163.270004  164.509995  164.509995   \n",
       "2008  2019-12-27  164.860001  165.460007  163.899994  164.979996  164.979996   \n",
       "2009  2019-12-30  164.860001  164.940002  161.199997  162.440002  162.440002   \n",
       "2010  2019-12-31  162.039993  163.259995  161.800003  162.639999  162.639999   \n",
       "\n",
       "      tic     zopen     zhigh      zlow  zadjcp    zclose      zd_5     zd_10  \\\n",
       "0     CRM  0.015490  0.020722 -0.012310     0.0 -0.036759 -0.000532 -0.014879   \n",
       "1     CRM -0.018528  0.011947 -0.036549     0.0  0.013233 -0.000532 -0.014879   \n",
       "2     CRM -0.020582  0.001880 -0.041658     0.0  0.023185 -0.000532 -0.014879   \n",
       "3     CRM  0.000695  0.010819 -0.012109     0.0 -0.003067 -0.008913 -0.014879   \n",
       "4     CRM -0.019181  0.000191 -0.029869     0.0  0.040099 -0.040271 -0.014879   \n",
       "...   ...       ...       ...       ...     ...       ...       ...       ...   \n",
       "2006  CRM  0.000368  0.003614 -0.002266     0.0 -0.002993  0.000123 -0.010077   \n",
       "2007  CRM -0.006747  0.000122 -0.007537     0.0  0.007718 -0.003854 -0.012723   \n",
       "2008  CRM -0.000727  0.002910 -0.006546     0.0  0.002857 -0.004691 -0.011662   \n",
       "2009  CRM  0.014898  0.015390 -0.007634     0.0 -0.015396  0.008274  0.004599   \n",
       "2010  CRM -0.003689  0.003812 -0.005165     0.0  0.001231  0.005681  0.003781   \n",
       "\n",
       "         zd_15     zd_20     zd_25     zd_30  \n",
       "0    -0.015927 -0.017220 -0.024889 -0.023492  \n",
       "1    -0.015927 -0.017220 -0.024889 -0.023492  \n",
       "2    -0.015927 -0.017220 -0.024889 -0.023492  \n",
       "3    -0.015927 -0.017220 -0.024889 -0.023492  \n",
       "4    -0.015927 -0.017220 -0.024889 -0.023492  \n",
       "...        ...       ...       ...       ...  \n",
       "2006 -0.018850 -0.016202 -0.013131 -0.011302  \n",
       "2007 -0.023091 -0.023138 -0.020556 -0.018540  \n",
       "2008 -0.023142 -0.024870 -0.023157 -0.020855  \n",
       "2009 -0.006049 -0.009761 -0.007991 -0.005670  \n",
       "2010 -0.005157 -0.010474 -0.009252 -0.007009  \n",
       "\n",
       "[2011 rows x 18 columns]"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "test[test[\"tic\"]==\"CRM\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "df = pd.read_csv(\"/home/sunshuo/qml/TradeMaster-1/data/data/dj30/train.csv\",index_col=0)\n",
    "df.sort_values(by='tic', ascending=True, inplace=True)\n",
    "array_symbols = df['tic'].values\n",
    "     \n",
    "    # get data, put into dictionary then dataframe\n",
    "dict_sym_ac = {}  # key=symbol, value=array of adj close\n",
    "for sym in array_symbols:\n",
    "    dftemp = df[df['tic']==sym]\n",
    "    dict_sym_ac[sym] = dftemp['adjcp'].values"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "dfdata = pd.DataFrame.from_dict(dict_sym_ac)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>AAPL</th>\n",
       "      <th>AMGN</th>\n",
       "      <th>AXP</th>\n",
       "      <th>BA</th>\n",
       "      <th>CAT</th>\n",
       "      <th>CRM</th>\n",
       "      <th>CSCO</th>\n",
       "      <th>CVX</th>\n",
       "      <th>DIS</th>\n",
       "      <th>GS</th>\n",
       "      <th>...</th>\n",
       "      <th>MRK</th>\n",
       "      <th>MSFT</th>\n",
       "      <th>NKE</th>\n",
       "      <th>PG</th>\n",
       "      <th>TRV</th>\n",
       "      <th>UNH</th>\n",
       "      <th>V</th>\n",
       "      <th>VZ</th>\n",
       "      <th>WBA</th>\n",
       "      <th>WMT</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>-0.143726</td>\n",
       "      <td>-0.187244</td>\n",
       "      <td>-0.051417</td>\n",
       "      <td>-0.028303</td>\n",
       "      <td>-0.104209</td>\n",
       "      <td>0.0</td>\n",
       "      <td>-0.132201</td>\n",
       "      <td>-0.184247</td>\n",
       "      <td>-0.079684</td>\n",
       "      <td>-0.077959</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.085375</td>\n",
       "      <td>-0.144286</td>\n",
       "      <td>-0.019071</td>\n",
       "      <td>-0.108631</td>\n",
       "      <td>-0.085600</td>\n",
       "      <td>-0.048781</td>\n",
       "      <td>-0.043989</td>\n",
       "      <td>-0.261781</td>\n",
       "      <td>-0.238961</td>\n",
       "      <td>-0.159209</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>-0.033829</td>\n",
       "      <td>-0.117670</td>\n",
       "      <td>-0.044098</td>\n",
       "      <td>-0.028303</td>\n",
       "      <td>-0.164935</td>\n",
       "      <td>0.0</td>\n",
       "      <td>-0.259982</td>\n",
       "      <td>-0.293476</td>\n",
       "      <td>-0.042380</td>\n",
       "      <td>-0.109496</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.269111</td>\n",
       "      <td>-0.035001</td>\n",
       "      <td>-0.093919</td>\n",
       "      <td>-0.250122</td>\n",
       "      <td>-0.189502</td>\n",
       "      <td>-0.051811</td>\n",
       "      <td>-0.037107</td>\n",
       "      <td>-0.252191</td>\n",
       "      <td>-0.167679</td>\n",
       "      <td>-0.169739</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>-0.018836</td>\n",
       "      <td>-0.183331</td>\n",
       "      <td>-0.109180</td>\n",
       "      <td>-0.028303</td>\n",
       "      <td>-0.100052</td>\n",
       "      <td>0.0</td>\n",
       "      <td>-0.169409</td>\n",
       "      <td>-0.241833</td>\n",
       "      <td>-0.049703</td>\n",
       "      <td>-0.151912</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.269111</td>\n",
       "      <td>-0.169419</td>\n",
       "      <td>-0.021624</td>\n",
       "      <td>-0.226484</td>\n",
       "      <td>-0.111320</td>\n",
       "      <td>-0.048781</td>\n",
       "      <td>-0.016858</td>\n",
       "      <td>-0.227279</td>\n",
       "      <td>-0.163773</td>\n",
       "      <td>-0.076608</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>-0.143726</td>\n",
       "      <td>-0.084720</td>\n",
       "      <td>-0.133151</td>\n",
       "      <td>-0.162010</td>\n",
       "      <td>-0.215922</td>\n",
       "      <td>0.0</td>\n",
       "      <td>-0.176936</td>\n",
       "      <td>-0.176611</td>\n",
       "      <td>-0.062566</td>\n",
       "      <td>-0.087050</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.215297</td>\n",
       "      <td>-0.090437</td>\n",
       "      <td>-0.101301</td>\n",
       "      <td>-0.058441</td>\n",
       "      <td>-0.058924</td>\n",
       "      <td>-0.105815</td>\n",
       "      <td>-0.020078</td>\n",
       "      <td>-0.353570</td>\n",
       "      <td>-0.167679</td>\n",
       "      <td>-0.076608</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>-0.059916</td>\n",
       "      <td>-0.123660</td>\n",
       "      <td>-0.085752</td>\n",
       "      <td>-0.032770</td>\n",
       "      <td>-0.226766</td>\n",
       "      <td>0.0</td>\n",
       "      <td>-0.219536</td>\n",
       "      <td>-0.224100</td>\n",
       "      <td>-0.062566</td>\n",
       "      <td>-0.072101</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.163054</td>\n",
       "      <td>-0.150727</td>\n",
       "      <td>-0.034601</td>\n",
       "      <td>-0.148780</td>\n",
       "      <td>-0.160105</td>\n",
       "      <td>-0.109173</td>\n",
       "      <td>-0.016858</td>\n",
       "      <td>-0.242993</td>\n",
       "      <td>-0.171341</td>\n",
       "      <td>-0.035546</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2006</th>\n",
       "      <td>-0.037206</td>\n",
       "      <td>-0.157928</td>\n",
       "      <td>-0.100902</td>\n",
       "      <td>-0.135686</td>\n",
       "      <td>-0.240687</td>\n",
       "      <td>0.0</td>\n",
       "      <td>-0.248984</td>\n",
       "      <td>-0.136248</td>\n",
       "      <td>-0.012074</td>\n",
       "      <td>-0.149351</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.103849</td>\n",
       "      <td>-0.156670</td>\n",
       "      <td>-0.079298</td>\n",
       "      <td>-0.190098</td>\n",
       "      <td>-0.080258</td>\n",
       "      <td>-0.079078</td>\n",
       "      <td>-0.026564</td>\n",
       "      <td>-0.294848</td>\n",
       "      <td>-0.130301</td>\n",
       "      <td>-0.153670</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2007</th>\n",
       "      <td>-0.125335</td>\n",
       "      <td>-0.157928</td>\n",
       "      <td>-0.051418</td>\n",
       "      <td>-0.047007</td>\n",
       "      <td>-0.072696</td>\n",
       "      <td>0.0</td>\n",
       "      <td>-0.237587</td>\n",
       "      <td>-0.316728</td>\n",
       "      <td>-0.056557</td>\n",
       "      <td>-0.092244</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.109922</td>\n",
       "      <td>-0.181610</td>\n",
       "      <td>-0.076518</td>\n",
       "      <td>-0.076954</td>\n",
       "      <td>-0.140747</td>\n",
       "      <td>-0.054999</td>\n",
       "      <td>-0.054524</td>\n",
       "      <td>-0.227279</td>\n",
       "      <td>-0.197474</td>\n",
       "      <td>-0.189646</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2008</th>\n",
       "      <td>-0.125336</td>\n",
       "      <td>-0.157929</td>\n",
       "      <td>-0.106526</td>\n",
       "      <td>-0.103167</td>\n",
       "      <td>-0.181719</td>\n",
       "      <td>0.0</td>\n",
       "      <td>-0.154915</td>\n",
       "      <td>-0.153121</td>\n",
       "      <td>-0.090907</td>\n",
       "      <td>-0.099471</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.209573</td>\n",
       "      <td>-0.150727</td>\n",
       "      <td>-0.052836</td>\n",
       "      <td>-0.195817</td>\n",
       "      <td>-0.080258</td>\n",
       "      <td>-0.144174</td>\n",
       "      <td>-0.047391</td>\n",
       "      <td>-0.369096</td>\n",
       "      <td>-0.222703</td>\n",
       "      <td>-0.039853</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2009</th>\n",
       "      <td>-0.037206</td>\n",
       "      <td>-0.221163</td>\n",
       "      <td>-0.100902</td>\n",
       "      <td>-0.017811</td>\n",
       "      <td>-0.138010</td>\n",
       "      <td>0.0</td>\n",
       "      <td>-0.072619</td>\n",
       "      <td>-0.322007</td>\n",
       "      <td>-0.035256</td>\n",
       "      <td>-0.077959</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.262152</td>\n",
       "      <td>-0.078367</td>\n",
       "      <td>-0.082195</td>\n",
       "      <td>-0.262806</td>\n",
       "      <td>-0.058924</td>\n",
       "      <td>-0.054999</td>\n",
       "      <td>-0.054524</td>\n",
       "      <td>-0.200686</td>\n",
       "      <td>-0.174580</td>\n",
       "      <td>-0.148941</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2010</th>\n",
       "      <td>-0.104143</td>\n",
       "      <td>-0.221163</td>\n",
       "      <td>-0.121507</td>\n",
       "      <td>-0.103167</td>\n",
       "      <td>-0.245507</td>\n",
       "      <td>0.0</td>\n",
       "      <td>-0.254500</td>\n",
       "      <td>-0.127749</td>\n",
       "      <td>-0.104656</td>\n",
       "      <td>-0.120587</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.150447</td>\n",
       "      <td>-0.061165</td>\n",
       "      <td>-0.066279</td>\n",
       "      <td>-0.243964</td>\n",
       "      <td>-0.210814</td>\n",
       "      <td>-0.045150</td>\n",
       "      <td>-0.061871</td>\n",
       "      <td>-0.200686</td>\n",
       "      <td>-0.193591</td>\n",
       "      <td>-0.035546</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>2011 rows × 29 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "          AAPL      AMGN       AXP        BA       CAT  CRM      CSCO  \\\n",
       "0    -0.143726 -0.187244 -0.051417 -0.028303 -0.104209  0.0 -0.132201   \n",
       "1    -0.033829 -0.117670 -0.044098 -0.028303 -0.164935  0.0 -0.259982   \n",
       "2    -0.018836 -0.183331 -0.109180 -0.028303 -0.100052  0.0 -0.169409   \n",
       "3    -0.143726 -0.084720 -0.133151 -0.162010 -0.215922  0.0 -0.176936   \n",
       "4    -0.059916 -0.123660 -0.085752 -0.032770 -0.226766  0.0 -0.219536   \n",
       "...        ...       ...       ...       ...       ...  ...       ...   \n",
       "2006 -0.037206 -0.157928 -0.100902 -0.135686 -0.240687  0.0 -0.248984   \n",
       "2007 -0.125335 -0.157928 -0.051418 -0.047007 -0.072696  0.0 -0.237587   \n",
       "2008 -0.125336 -0.157929 -0.106526 -0.103167 -0.181719  0.0 -0.154915   \n",
       "2009 -0.037206 -0.221163 -0.100902 -0.017811 -0.138010  0.0 -0.072619   \n",
       "2010 -0.104143 -0.221163 -0.121507 -0.103167 -0.245507  0.0 -0.254500   \n",
       "\n",
       "           CVX       DIS        GS  ...       MRK      MSFT       NKE  \\\n",
       "0    -0.184247 -0.079684 -0.077959  ... -0.085375 -0.144286 -0.019071   \n",
       "1    -0.293476 -0.042380 -0.109496  ... -0.269111 -0.035001 -0.093919   \n",
       "2    -0.241833 -0.049703 -0.151912  ... -0.269111 -0.169419 -0.021624   \n",
       "3    -0.176611 -0.062566 -0.087050  ... -0.215297 -0.090437 -0.101301   \n",
       "4    -0.224100 -0.062566 -0.072101  ... -0.163054 -0.150727 -0.034601   \n",
       "...        ...       ...       ...  ...       ...       ...       ...   \n",
       "2006 -0.136248 -0.012074 -0.149351  ... -0.103849 -0.156670 -0.079298   \n",
       "2007 -0.316728 -0.056557 -0.092244  ... -0.109922 -0.181610 -0.076518   \n",
       "2008 -0.153121 -0.090907 -0.099471  ... -0.209573 -0.150727 -0.052836   \n",
       "2009 -0.322007 -0.035256 -0.077959  ... -0.262152 -0.078367 -0.082195   \n",
       "2010 -0.127749 -0.104656 -0.120587  ... -0.150447 -0.061165 -0.066279   \n",
       "\n",
       "            PG       TRV       UNH         V        VZ       WBA       WMT  \n",
       "0    -0.108631 -0.085600 -0.048781 -0.043989 -0.261781 -0.238961 -0.159209  \n",
       "1    -0.250122 -0.189502 -0.051811 -0.037107 -0.252191 -0.167679 -0.169739  \n",
       "2    -0.226484 -0.111320 -0.048781 -0.016858 -0.227279 -0.163773 -0.076608  \n",
       "3    -0.058441 -0.058924 -0.105815 -0.020078 -0.353570 -0.167679 -0.076608  \n",
       "4    -0.148780 -0.160105 -0.109173 -0.016858 -0.242993 -0.171341 -0.035546  \n",
       "...        ...       ...       ...       ...       ...       ...       ...  \n",
       "2006 -0.190098 -0.080258 -0.079078 -0.026564 -0.294848 -0.130301 -0.153670  \n",
       "2007 -0.076954 -0.140747 -0.054999 -0.054524 -0.227279 -0.197474 -0.189646  \n",
       "2008 -0.195817 -0.080258 -0.144174 -0.047391 -0.369096 -0.222703 -0.039853  \n",
       "2009 -0.262806 -0.058924 -0.054999 -0.054524 -0.200686 -0.174580 -0.148941  \n",
       "2010 -0.243964 -0.210814 -0.045150 -0.061871 -0.200686 -0.193591 -0.035546  \n",
       "\n",
       "[2011 rows x 29 columns]"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dfdata"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(2011, 29)"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dfdata.values.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3.7.13 ('TradeMaster')",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.13"
  },
  "orig_nbformat": 4,
  "vscode": {
   "interpreter": {
    "hash": "a1f97403911abd3f02553c8f2b0c54537fddc7efadd9f5d3e31784db6e40c347"
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
